#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Solution
{
public:
    int findPairs(vector<int> &nums, int k)
    {
        sort(nums.begin(), nums.end());
        
        int left = 0, right = 0, sum = 0;

        while (left < nums.size())
        {
            if (left > 0 && nums[left] == nums[left - 1])
            {
                left = left + 1;
            }
            else
            {
                right = 0;

                while (right < nums.size())
                {
                    if (right > 0 && nums[right] == nums[right - 1])
                    {
                        right = right + 1;
                    }
                    else if (nums[right] - nums[left] == k)
                    {
                        sum = sum + 1;
                        cout << left << " " << right << endl;
                        break;
                    }
                    else if (nums[right] - nums[left] > k)
                    {
                        break;
                    }
                    else
                    {
                        right = right + 1;
                    }
                }

                left = left + 1;
            }
        }

        return sum;
    }
};

int main()
{
    return 0;
}